import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import moment from 'moment';
import styles from './RecommItem.less';
import {
  Row,
  Col,
  Card,
  Form,
  Input,
  Select,
  Button,
  Modal,
  Avatar,
  message,
  Badge,
  Radio,
  Upload,
  Icon,
  Popconfirm,
} from 'antd';

@Form.create()
export default class PadRecommItem extends PureComponent {
  constructor(props) {
    super(props);

    console.log('初始化数据', this.props.initValue)

    this.state = {
      fileList: [],
      file: null,
    };
  }

  oper(type) {
    this.props.changeSts(type);
  }

  render() {
    const { item } = this.props;
    return (
      <div className={styles.container} key={item.recommId}>
        <Card>{item.recommName}</Card>
        <div>
          <div className={item.recommSts == "1" ? styles.statusButton : styles.statusButton1}>
            {item.recommSts == "0" ? '未上线' : item.recommSts == "1" ? '已上线' : item.recommSts == "2" ? '已下线' : '未上线'}
          </div>
        </div>
        <div>
          <Button onClick={() => this.props.edit()}>编辑</Button>
          <Popconfirm title="确定要删除该推荐页吗?" placement="top" onConfirm={() => this.props.delete()} onCancel={() => { }} okText="确定" cancelText="取消">
            <Button>删除</Button>
          </Popconfirm>
          {item.recommSts != '1' ?
            <Button onClick={() => this.props.changeSts(1)}>上线</Button>
            : null
          }
          {item.recommSts != '2' ?
            <Button onClick={() => this.props.changeSts(2)}>下线</Button>
            : null
          }
        </div>
      </div>
    )
  }
}